-- Credits
-- 开发人员名单

Credits = class()

function Credits:init()
    self.backButton = TextButton(55,HEIGHT - 40,LP.Back)
    self.backButton.font = "Futura-Medium"
    self.backButton.fontSize = 30
    self.backButton.clicked = function()
        self.showing = false
        self.appearing = true
        self.yOffset = 0
        tween(1,self,{yOffset = HEIGHT},tween.easing.quartOut,function() self.appearing = false end)
    end
    self.backButton.backColor = color(255, 255, 255, 0)
    self.backButton.textColor = color(255, 255, 255, 255)
    
    self.codeaInfo = ImageButton(WIDTH - 120,30,"Project:MadeWithCodea")
    self.codeaInfo.width = 200
    self.codeaInfo.color = color(255, 255, 255, 152)
    self.codeaInfo.pressedColor = color(127, 127, 127, 209)
    self.codeaInfo.clicked = function()
        openURL("itms-apps://itunes.com/apps/Codea")
    end
    
    self.showing = false
    self.yOffset = 0
end

function Credits:show()
    self.appearing = true
    self.yOffset = HEIGHT
    tween(1,self,{yOffset = 0},tween.easing.quartOut,function() self.showing = true self.appearing = false end)
end

function Credits:draw()
    if not self.showing and not self.appearing then
        return
    end
    
    if self.appearing then
        translate(0,self.yOffset)
    end
    
    noStroke()
    fill(41, 41, 41, 255)
    rectMode(CORNER)
    rect(0,0,WIDTH,HEIGHT)
    fill(255, 255, 255, 255)
    font("SourceSansPro-Regular")
    textMode(CENTER)
    fontSize(100)
    text(LP.TC,WIDTH / 2,HEIGHT * 0.85)
    fontSize(35)
    text(LP.Develop,WIDTH / 2,HEIGHT * 0.7)
    fontSize(25)
    text(LP.MainDeveloper,WIDTH * 0.3,HEIGHT * 0.55)
    text(LP.Developer,WIDTH * 0.3,HEIGHT * 0.4)
    fontSize(30)
    text(LP.Powered,WIDTH * 0.7,HEIGHT * 0.6)
    tint(255, 255, 255, 255)
    spriteMode(CENTER)
    sprite("Project:Codea Icon",WIDTH * 0.7,HEIGHT * 0.37)
    
    self.backButton:draw()
    self.codeaInfo:draw()
end

function Credits:touched(touch)
    self.backButton:touched(touch)
    self.codeaInfo:touched(touch)
end
